We use the online SMS service from http://clickatell.com/ en first need an account to access it. Clickatell offers a test acccount with a limited amount of free SMS messages. Different other services exist and your own mobile operator may offer a service as well, but then the below code needs to be adapted to your their API.
After creating an account, you need to add a REST API in the interface, which Clickatell will generate an Auth(entication) Token. This token has to be filled in below:
In [ ]:
TOKEN = "****************************************************************"
DEST = "32475******"
In [ ]:
from clickatell.rest import Rest
clickatell = Rest(TOKEN);
In [ ]:
response = clickatell.sendMessage([DEST], "Raspi wants to be your BFF forever", extra={'from':'32477550561'})
# the extra['from'] parameters can be used to put any phone number, but it needs to be registered
# in the Clickatell administration interface
In [ ]:
print response
In [ ]:
for entry in response:
print('destination {}:'.format(entry['destination']))
for key in entry.keys():
print(" {}: {}".format(key, entry[key]))
In [ ]: